<!DOCTYPE html>
<html lang="zh-CN">
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
		<meta name="description" content="">
		<meta name="author" content="">
		<link rel="icon" href="../../favicon.ico">

		<title>内部订餐系统</title>

		<!-- Bootstrap core CSS -->
		<!--link href="//cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"-->
		<link href="/javascripts/bootstrap.min.css" rel="stylesheet">

		<!-- Custom styles for this template -->
		<link href="/javascripts/starter-template.css" rel="stylesheet">
		<link href="/javascripts/jquery.min.js">
		<script src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script>
		<script src="http://apps.bdimg.com/libs/bootstrap/3.3.0/js/bootstrap.min.js"></script>
		<!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
		<!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
		<!--script src="./public/order.js"></script-->
		<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
		<!--[if lt IE 9]>
		<script src="//cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
		<script src="//cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
		<![endif]-->
		<script src="../../assets/js/ie-emulation-modes-warning.js"></script>
		<script type="text/javascript">
			$(document).ready(function(){
      	$("#login").click(function(){
          var username = $("#username").val();
          var password = $("#password").val();
					if (username.length === 0) {
						alert('用户名为空');
						return;
					}

					if (password.length === 0) {
						alert('密码为空');
						return;
					}
          var data = {"username":username,"password":password};
          $.ajax({
              url:'/login',
              type:'post',
              data: data,
              success: function(data,status){
                  if(status == 'success'){
                      location.href = 'home';
                  }
              },
              error: function(data,status){
                  if(status == 'error'){
                      location.href = 'login';
                  }
              }
          });
      	});
    	});
		</script>
	</head>

	<body>
		<div class="container">
			<%- message %>
			<div class="starter-template">
				<form class="form-horizontal logindiv" role="form" method="post">
					<div class="form-group" role="form">
						<label for="username" class="col-sm-2 control-label">用户名</label>
						<div class="col-sm-10">
							<input type="text" class="form-control" name="username"
							placeholder="请输入用户名" id="username">
						</div>
					</div>
					<div class="form-group">
						<label for="password" class="col-sm-2 control-label">密码</label>
						<div class="col-sm-10 ">
							<input type="password" class="form-control" name="password"
							placeholder="请输入密码" id="password">
						</div>
					</div>
					<div class="form-group">
						<div class="col-sm-offset-1 col-sm-10">
							<button type="button" class="btn btn-default btn-lg" id="login" >登录</button>
              <a class="btn btn-default btn-lg" href="/register" >注册</a>
            </div>
					</div>
				</form>
			</div>

		</div><!-- /.container -->


		<!-- Bootstrap core JavaScript
		================================================== -->
		<!-- Placed at the end of the document so the pages load faster -->
		<!--script src="//cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script-->
		<!--script src="//cdn.bootcss.com/bootstrap/3.3.5/js/bootstrap.min.js"></script-->
		<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
		<!--script src="../../assets/js/ie10-viewport-bug-workaround.js"></script-->
	</body>
</html>
